//
//  CXYBaseNavigationController.swift
//  诚叙缘
//
//  Created by sujeking on 17/3/20.
//  Copyright © 2017年 szw. All rights reserved.
//

import UIKit

class CXYBaseNavigationController: UINavigationController {

    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setupUI()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    func setupUI() {
        self.navigationBar.barTintColor = navBarBGColor
        self.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:#colorLiteral(red: 0.2549019608, green: 0.2549019608, blue: 0.2549019608, alpha: 1)]
        self.navigationBar.tintColor = #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)
        self.navigationBar.isTranslucent = false
        
        self.navigationBar.setBackgroundImage(#imageLiteral(resourceName: "navbarbg"), for: UIBarMetrics.default)
        self.navigationBar.shadowImage = #imageLiteral(resourceName: "navshadow")
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if self.viewControllers.count == 1 {
            let app = UIApplication.shared.delegate as! AppDelegate
            app.mainViewController?.hiddenTabBar(next: { 
                super.pushViewController(viewController, animated: animated)
            })
            return
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    override func popViewController(animated: Bool) -> UIViewController? {
        let app = UIApplication.shared.delegate as! AppDelegate
        if self.viewControllers.count == 2 {
            app.mainViewController?.showTabBar()
        }
        return super.popViewController(animated: animated)
    }
}
